﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;
using Pow.components;

namespace Pow {
	class Jogador {
		private Game1 game1;
		private Texture2D mira;
        private Texture2D bgimg;
		public Rectangle miraBounder;
		public bool atirando = false;
        public bool gameover = false;
		private Vector2 posicaoMira;
        private Vector2 posicaoBgimg;
        private float rotacao = 0.1f;
        public Color miraCor = Color.Aqua;
		//Sons
		public SoundEffect tiroFX;
		public SoundEffect explosaoFX;
		public SoundEffect evilFX;
		private Song fundo;
		public int life = 10;
		public int score = 0;
		HUD hud;


		public Jogador(Game1 game1) {
			this.game1 = game1;
			loadContent();
			initialize();
		}

		private void initialize() {
			posicaoMira = new Vector2(400 - mira.Width / 2, 300 - mira.Height / 2);
            posicaoBgimg = new Vector2(600, 200);
			miraBounder = new Rectangle((int) posicaoMira.X, (int) posicaoMira.Y, mira.Width, mira.Height);
			hud = new HUD(game1);

		}

		private void loadContent() {
            bgimg = game1.Content.Load<Texture2D>("saturno");
			mira = game1.Content.Load<Texture2D>("Mira");
			tiroFX = game1.Content.Load<SoundEffect>("Sons/tiro_gerador");
			explosaoFX = game1.Content.Load<SoundEffect>("Sons/explosao_gerador");
			evilFX = game1.Content.Load<SoundEffect>("Sons/Arcade15");
			fundo = game1.Content.Load<Song>("Sons/trumpet_SOUNDDOGS__vo");
			MediaPlayer.IsRepeating = true;
			MediaPlayer.Play(fundo);
		}

		public void draw(GameTime gameTime) {


            game1.spriteBatch.Draw(bgimg, posicaoBgimg, new Rectangle(0, 0, 1800, 1349), Color.White, rotacao, new Vector2(900,674), 1f, SpriteEffects.None, 0);	
            game1.spriteBatch.Draw(mira, posicaoMira, miraCor);
        
                //game.spriteBatch.Draw(texture, myPosition, new Rectangle(140 * frame, 0, 140, 140), Color.White, 0f, Vector2.Zero, .5f, SpriteEffects.None, 0);

		}

		public void Update(GameTime gameTime, EnemyFactory enemyfactory) {
            rotacao += .001f;

            if (life < 1)
            {
                //game1.currentState = Game1.GameState.GameOver;
                gameover = true;
                game1.gameover = true;
            }
			
		}


 


	}
}
